package com.meixiang.entity.shopping.result;

import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;

import com.meixiang.entity.shopping.GoodsDetailEntity;
import com.meixiang.entity.shopping.GoodsGroupEntity;

/**
 * 商品详情Result
 *
 * @author LZRUI
 */
public class GoodsDetailResult implements Parcelable {

    private String goodsId; // 商品id
    private String storeId; // 店铺编号
    private String storeName; // 店铺名称
    private String isFavorite; // 是否收藏 "Y"/"N"
    private String[] note; // 商品标签（"正品保证","品牌授权","7天包换"）
    private String isGroup; // 是否有组合商品 "Y"/"N"
    private GoodsDetailEntity goods; // 商品详细信息
    private GoodsGroupEntity goodsGroup; // 套装列表
    private String isHeadQuarter; // 1是，0不是

    public GoodsDetailResult(String goodsId, String storeId, String storeName, String isFavorite, String[] note, String isGroup, GoodsDetailEntity goods, GoodsGroupEntity goodsGroup) {
        this.goodsId = goodsId;
        this.storeId = storeId;
        this.storeName = storeName;
        this.isFavorite = isFavorite;
        this.note = note;
        this.isGroup = isGroup;
        this.goods = goods;
        this.goodsGroup = goodsGroup;
    }

    public GoodsDetailResult(String goodsId, String storeId, String storeName, String isFavorite, String[] note, String isGroup, GoodsDetailEntity goods, GoodsGroupEntity goodsGroup, String isHeadQuarter) {
        this.goodsId = goodsId;
        this.storeId = storeId;
        this.storeName = storeName;
        this.isFavorite = isFavorite;
        this.note = note;
        this.isGroup = isGroup;
        this.goods = goods;
        this.goodsGroup = goodsGroup;
        this.isHeadQuarter = isHeadQuarter;
    }

    public GoodsDetailResult() {

    }

    public String getGoodsId() {
        return goodsId == null ? "" : goodsId;
    }

    public void setGoodsId(String goodsId) {
        this.goodsId = goodsId;
    }

    public String getStoreId() {
        return storeId == null ? "" : storeId;
    }

    public void setStoreId(String storeId) {
        this.storeId = storeId;
    }

    public String getStoreName() {
        return storeName == null ? "" : storeName;
    }

    public void setStoreName(String storeName) {
        this.storeName = storeName;
    }

    public String getIsFavorite() {
        return isFavorite == null ? "N" : isFavorite;
    }

    public void setFavorite(String favorite) {
        isFavorite = favorite;
    }

    public String[] getNote() {
        return note;
    }

    public void setNote(String[] note) {
        this.note = note;
    }

    public String getIsGroup() {
        return isGroup == null ? "N" : isGroup;
    }

    public void setGroup(String group) {
        isGroup = group;
    }

    public GoodsDetailEntity getGoods() {
        return goods;
    }

    public void setGoods(GoodsDetailEntity goods) {
        this.goods = goods;
    }

    public GoodsGroupEntity getGoodsGroup() {
        return goodsGroup;
    }

    public void setGoodsGroup(GoodsGroupEntity goodsGroup) {
        this.goodsGroup = goodsGroup;
    }

    public String getIsHeadQuarter() {
        return isHeadQuarter == null ? "" : isHeadQuarter;
    }

    public void setIsHeadQuarter(String isHeadQuarter) {
        this.isHeadQuarter = isHeadQuarter;
    }

    public boolean isGroup() {
        if (!TextUtils.isEmpty(isGroup) && isGroup.equals("Y")) {
            return true;
        } else {
            return false;
        }
    }

    public boolean isFavorite() {
        if (!TextUtils.isEmpty(isFavorite) && isFavorite.equals("Y")) {
            return true;
        } else {
            return false;
        }
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.goodsId);
        dest.writeString(this.storeId);
        dest.writeString(this.storeName);
        dest.writeString(this.isFavorite);
        dest.writeStringArray(this.note);
        dest.writeString(this.isGroup);
        dest.writeParcelable(this.goods, flags);
        dest.writeParcelable(this.goodsGroup, flags);
        dest.writeString(this.isHeadQuarter);
    }

    protected GoodsDetailResult(Parcel in) {
        this.goodsId = in.readString();
        this.storeId = in.readString();
        this.storeName = in.readString();
        this.isFavorite = in.readString();
        this.note = in.createStringArray();
        this.isGroup = in.readString();
        this.goods = in.readParcelable(GoodsDetailEntity.class.getClassLoader());
        this.goodsGroup = in.readParcelable(GoodsGroupEntity.class.getClassLoader());
        this.isHeadQuarter = in.readString();
    }

    public static final Creator<GoodsDetailResult> CREATOR = new Creator<GoodsDetailResult>() {
        @Override
        public GoodsDetailResult createFromParcel(Parcel source) {
            return new GoodsDetailResult(source);
        }

        @Override
        public GoodsDetailResult[] newArray(int size) {
            return new GoodsDetailResult[size];
        }
    };
}
